﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ALL_Tool
{
    internal class PublicMethod
    {

        //公共类，读取配置文件，获取连接信息方便调用
        public static string Sql_Link_Str()
        {
            // 从配置文件中读取数据库连接信息
            string ip = ConfigurationManager.AppSettings["ip"];
            string port = ConfigurationManager.AppSettings["port"];
            string database = ConfigurationManager.AppSettings["database"];
            string username = ConfigurationManager.AppSettings["username"];
            string password = ConfigurationManager.AppSettings["password"];
            // 构造连接字符串
            string connectionString = $"Server={ip},{port};Database={database};User Id={username};Password={password};";
            return connectionString;
        }
        public static string GetLogoPath(string logoFileName)
        {
            //获取根目录
            string rootPath = AppDomain.CurrentDomain.BaseDirectory;
            //定义 资源文件夹路径
            string resourceFolderPath = Path.Combine(rootPath, "resource");
            //拼接 logo文件真实路径
            string logoPath = Path.Combine(resourceFolderPath, logoFileName);
            //返回 log路径
            return logoPath;
        }
        
    }
}
